/*
 * @lc app=leetcode.cn id=1614 lang=javascript
 *
 * [1614] 括号的最大嵌套深度
 */

// @lc code=start
/**
 * @param {string} s
 * @return {number}
 */
var maxDepth = function (s) {
  const stack = [];
  let max = 0;
  s.split('').forEach(ch => {
    if (ch === '(') {
      stack.push('(');
      max = Math.max(max, stack.length);
    } else if (ch === ')') {
      stack.pop();
    }
  });
  return max;
};
// @lc code=end

